package com.kalix.mooc.recommend.biz;

import com.kalix.framework.core.api.persistence.JsonData;
import com.kalix.framework.core.impl.biz.ShiroGenericBizServiceImpl;
import com.kalix.mooc.recommend.api.biz.IHotlistsTeacherBeanService;
import com.kalix.mooc.recommend.api.dao.IHotlistsTeacherBeanDao;
import com.kalix.mooc.recommend.api.dto.HotlistsTeacherDTO;
import com.kalix.mooc.recommend.entities.HotlistsTeacherBean;

import java.util.List;

public class HotlistsTeacherBeanServiceImpl extends ShiroGenericBizServiceImpl<IHotlistsTeacherBeanDao, HotlistsTeacherBean>
implements IHotlistsTeacherBeanService {
    /**
     * 推荐教师（关联表：用户表）
     * @return jsondata
     */
    @Override
    public JsonData getAllHotlistsTeacher() {
        String sql = "select t.id,t.identify,t.uid,u.name as uname,u.icon from mooc_hotliststeacher t,sys_user u where u.id = t.uid ORDER BY t.identify";
        List<HotlistsTeacherDTO> list = dao.findByNativeSql(sql, HotlistsTeacherDTO.class);
        JsonData jsonData = new JsonData();
        jsonData.setData(list);
        jsonData.setTotalCount((long) list.size());
        return jsonData;
    }
}
